package com.tb.ClassSchedule;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import java.util.HashSet;

/**
 * Created by guich on 2016/8/21.
 */
public class LessonDatabaseHelper extends SQLiteOpenHelper{


    public static final String CREATE_TABLE = "create table Lesson ("
            + "id integer primary key autoincrement, "
            + "ClassName text, "
            + "WeekDay integer, "
            + "StartSection integer, "
            + "EndSection integer, "
            + "StartWeek integer, "
            + "EndWeek integer, "
            + "TeacherName text, "
            + "Address text)";


    public LessonDatabaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        sqLiteDatabase.execSQL(CREATE_TABLE);


//        HashSet<Lesson> defaultLessonSet = new HashSet<>();
//        defaultLessonSet.add(new Lesson("微机原理与接口技术", 1, 1, 2, 1, 16, "周秋平", "逸夫楼A204"));
//        defaultLessonSet.add(new Lesson("软件工程", 1, 3, 4, 1, 16, "范庆春", "逸夫楼A306"));
//        defaultLessonSet.add(new Lesson("面向对象程序设计", 1, 5, 6, 5, 16, "樊高雁", "博约楼301*"));
//        defaultLessonSet.add(new Lesson("操作系统", 2, 3, 4, 1, 12, "王凡", "逸夫楼A205*"));
//        defaultLessonSet.add(new Lesson("计算机组成原理", 2, 5, 6, 1, 12, "王大刚", "逸夫楼A106*"));
//        defaultLessonSet.add(new Lesson("计算机组成原理", 2, 5, 6, 13, 16, "王大刚", "躬行楼312"));
//        defaultLessonSet.add(new Lesson("西方美术欣赏", 2, 9, 11, 3, 13, "夏文玲", "逸夫楼A101*"));
//        defaultLessonSet.add(new Lesson("软件工程", 3, 1, 2, 1, 16, "范庆春", "逸夫楼A309"));
//        defaultLessonSet.add(new Lesson("微机原理与接口技术", 3, 3, 4, 1, 16, "周秋平", "逸夫楼A303"));
//        defaultLessonSet.add(new Lesson("操作系统", 4, 1, 2, 1, 12, "王凡", "逸夫楼A106*"));
//        defaultLessonSet.add(new Lesson("面向对象程序设计", 4, 3, 4, 5, 16, "樊高雁", "逸夫楼A204*"));
//        defaultLessonSet.add(new Lesson("计算机网络实验", 4, 7, 8, 9, 16, "郭玉堂", "躬行楼302"));
//        defaultLessonSet.add(new Lesson("操作系统", 5, 3, 4, 5, 12, "王凡", "逸夫楼A106*"));
//        defaultLessonSet.add(new Lesson("计算机组成原理", 5, 5, 6, 1, 12, "王大刚", "逸夫楼A106*"));
//        defaultLessonSet.add(new Lesson("计算机组成原理", 5, 5, 6, 13, 16, "王大刚", "躬行楼312"));
//
//
//        ContentValues values = new ContentValues();
//        for (Lesson lesson : defaultLessonSet) {
//            values.put("ClassName", lesson.getName());
//            values.put("WeekDay", lesson.getWeekday());
//            values.put("StartSection", lesson.getStartSection());
//            values.put("EndSection", lesson.getEndSection());
//            values.put("StartWeek", lesson.getStartWeek());
//            values.put("EndWeek", lesson.getEndWeek());
//            values.put("TeacherName", lesson.getTeacher());
//            values.put("Address", lesson.getAddress());
//
//            sqLiteDatabase.insert("Lesson", null, values); //  插入第一条数据
//            values.clear();
//        }




    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {

    }
}
